package cn.etgps.etgps.ui;

import android.os.Bundle;

import com.amap.api.maps.AMap;
import com.amap.api.maps.MapView;

import cn.etgps.etgps.R;
import cn.etgps.etgps.base.BaseActivity;
import cn.etgps.etgps.view.TitleBar;

/**
 * 所有地图相关界面的父类，提供最基本的地图显示，通过继承该类只需要添加定位，标记等类似功能，不需要重复设置MapVIew
 */
public class MapActivity extends BaseActivity {
    /**
     * 地图显示控件
     */
    protected MapView mMapView = null;
    /**
     * 地图类
     */
    protected AMap mAMap = null;
    /**
     * 默认的标题栏
     */
    protected TitleBar mTitlebarView = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);
        mMapView = (MapView) findViewById(R.id.map);
        mMapView.onCreate(savedInstanceState);// 此方法必须重写
        if (mAMap == null) {
            mAMap = mMapView.getMap();
        }
        mTitlebarView = (TitleBar) findViewById(R.id.title_bar);
        initTitle();
    }

    /**
     * 子类需要集成去修改标题设置
     */
    protected void initTitle() {

    }

    @Override
    protected void onResume() {
        super.onResume();
        mMapView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mMapView.onPause();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mMapView.onSaveInstanceState(outState);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mMapView.onDestroy();
    }
}
